#include <iostream>
#include <deque>
#include <list>
#include <string>
#include <vector>
using namespace std;
void practice_9_18();
void practice_9_19();
void practice_9_20();
void practice_9_21();
void practice_9_24();
void practice_9_25();
void practice_9_26();
void practice_9_33();
void practice_9_34();
int main()
{
	//practice_9_18();
	//practice_9_19();
	//practice_9_20();
	//practice_9_21();
	//practice_9_24();
	//practice_9_25();
	//practice_9_26();
	//practice_9_33();
	practice_9_34();
	return 0;
}
void practice_9_18()
{
	string word;
	deque<string> q;
	auto iter=q.begin();
	while(cin>>word)
		iter=q.insert(iter,word);
	for(auto it=q.cbegin();it!=q.cend();++it)
		cout<<*it<<" ";
}
void practice_9_19()
{
	string word;
	list<string> li;
	auto iter=li.begin();
	while(cin>>word)
		iter=li.insert(iter,word);
	for(auto it=li.cbegin();it!=li.cend();++it)
		cout<<*it<<" ";
}
void practice_9_20()
{
	list<int> li{1,2,3,4,5,6,7,8,9};
	deque<int> q1,q2;
	for(auto it=li.cbegin();it!=li.cend();++it)
	{
		if((*it%2)!=0)
			q1.push_back(*it);
		else
			q2.push_back(*it);
	}	
	for(auto q:q1)
		cout<<q<<" ";
	cout<<endl;
	for(auto q:q2)
		cout<<q<<" ";
}
void practice_9_21()
{
	string word;
	vector<string> v;
	auto iter=v.begin();
	while(cin>>word)
		iter=v.insert(iter,word);
	for(auto s:v)
		cout<<s<<" ";
}
void practice_9_24()
{
	vector<int> v;
	//auto a=v[0];
	//auto a=v.front();
	//a=*v.begin();
	auto a=v.at(0);
}
void practice_9_25()
{
	vector<int> v{1,2,3,4,5,6,7};
	v.erase(v.begin()+1,v.end()-1);
	for(auto c:v)
		cout<<c<<" ";
}
void practice_9_26()
{
	int ia[]={0,1,1,2,3,5,8,13,21,55,89};
	vector<int> v(begin(ia),end(ia));
	list<int> l(begin(ia),end(ia));
	auto vit=v.begin();
	auto lit=l.begin();
	while(lit!=l.end()&&vit!=v.end()){
		if(*lit%2){
			lit=l.erase(lit);
			++vit;
		}
		else{
			vit=v.erase(vit);
			++lit;
		}
	}
	for(auto c:v)
		cout<<c<<" ";
	cout<<endl;
	for(auto c:l)
		cout<<c<<" ";
}
void practice_9_33()
{
	vector<int> v{1,2,3,4,5,6,7,8};
	auto begin=v.begin();
	while(begin!=v.end()){
		++begin;
		v.insert(begin,42);
		++begin;
	}
	for(auto c:v)
		cout<<c<<" ";
}
void practice_9_34()
{
	vector<int> v{1,2,3,4,5,6,7,8};
	auto iter=v.begin();
	while(iter!=v.end()){
		if(*iter%2){
			iter=v.insert(iter,*iter);
			iter+=2;
		}
		else
			++iter;
	}
	for(auto c:v)
		cout<<c<<" ";
}
